//
//  PFMainViewController.swift
//  weibo
//
//  Created by 薛鹏飞 on 16/9/19.
//  Copyright © 2016年 zuankuangren. All rights reserved.
//

import UIKit

class PFMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //创建tabbar对象
        let addBar = PFTabBar()
        
        setValue(addBar, forKey: "tabBar")
        
        
        addChildViewController(childController: PFHomeTableViewController(), title: "首页", image: "tabbar_home")
        addChildViewController(childController: PFMessageTableViewController(), title: "消息", image: "tabbar_message_center")
        addChildViewController(childController: PFDiscoverTableViewController(), title: "发现", image: "tabbar_discover")
        addChildViewController(childController: PFMineTableViewController(), title: "我的", image: "tabbar_profile")
        
        
        
    }
    
    
    func addChildViewController(childController: UIViewController,title: String,image :String) {
        
        childController.tabBarItem.image = UIImage(named: image)
        childController.tabBarItem.selectedImage = UIImage(named: "\(image)_selected")?.withRenderingMode(.alwaysOriginal)
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orange], for: .selected )
        childController.tabBarItem.title = title
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
        
        
        
        
    }
    
}
